/**
 * 2024/01/01 - 2024/12/31
 **/
package com.snail.camunda.engin.identity.controller;

import com.snail.camunda.engin.identity.dto.TenantInsertDTO;
import com.snail.camunda.engin.identity.dto.TenantModifyDTO;
import com.snail.camunda.engin.identity.dto.TenantQueryDTO;
import com.snail.camunda.engin.identity.manager.TenantManager;
import com.snail.camunda.engin.identity.vo.TenantVO;
import com.snail.starter.commons.page.PageQO;
import com.snail.starter.commons.page.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: (zg)
 * @Date: 2024/12/16 14:52
 * @Version: 1.0.0
 */
@Api(tags = {"租户管理"})
@RestController
@RequestMapping("/tenant")
public class TenantController {

    @Resource
    TenantManager tenantManager;

    @PostMapping
    @ApiOperation("新增租户")
    public String add(@RequestBody TenantInsertDTO dto) {
        return tenantManager.add(dto);
    }

    @PutMapping("/{id}")
    @ApiOperation("修改租户")
    public boolean modify(@PathVariable("id") String id, @RequestBody TenantModifyDTO dto) {
        return tenantManager.modify(id, dto);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除租户")
    public boolean delete(@PathVariable("id") String id) {
        return tenantManager.delete(id);
    }

    @GetMapping("/{id}")
    @ApiOperation("查询租户")
    public TenantVO queryById(@PathVariable("id") String id) {
        return tenantManager.queryById(id);
    }

    @PostMapping("/tenants")
    @ApiOperation("租户列表")
    public List<TenantVO> list(@RequestBody TenantQueryDTO dto) {
        return tenantManager.list(dto);
    }

    @PostMapping("/pages")
    @ApiOperation("租户列表(分页)")
    public PageVO<TenantVO> page(PageQO<String> page) {
        return tenantManager.page(page);
    }

}